package com.tools.web.work.excel.poi;

import com.tools.common.object.Note;
import org.apache.poi.ss.usermodel.PictureData;

import java.util.Objects;

/**
 * 从 Excel 读取到的图片的包装类对象
 * */
@Note("从 Excel 读取到的图片的包装类对象")
public class ExcelImg {

    @Note("图片数据")
    private final PictureData pictureData;

    @Note("图片所在的起始行索引")
    private final int startRow;

    @Note("图片所在的结束行索引")
    private final int endRow;

    public ExcelImg(PictureData pictureData, int startRow, int endRow) {
        this.pictureData = pictureData;
        this.startRow = startRow;
        this.endRow = endRow;
    }


    public PictureData getPictureData() {
        return pictureData;
    }

    public int getStartRow() {
        return startRow;
    }

    public int getEndRow() {
        return endRow;
    }

    public boolean inRangeRow(int rowIndex) {
        return rowIndex >= startRow && rowIndex < endRow;
    }

    @Override
    public String toString() {
        return "ExcelImg{" +
                "startRow=" + startRow +
                ", endRow=" + endRow +
                ", pictureData=" + pictureData +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ExcelImg excelImg = (ExcelImg) o;
        return startRow == excelImg.startRow && endRow == excelImg.endRow;
    }

    @Override
    public int hashCode() {
        return Objects.hash(startRow, endRow);
    }
}
